package com.mzj.saas.mservice.auth.controller;

import com.mzj.saas.annotation.RepeatSubmit;
import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.auth.service.InitFaceVerifyService;
import com.mzj.saas.mservice.auth.vo.AuthenticationVo;
import com.mzj.saas.mservice.auth.vo.RealPeopleCertificationVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 实人认证
 * @author shun
 * @createDate: 2022年6月9日 下午8:39:02
 * @version: 1.0
 *
 */
@Controller
@RequestMapping("/auth")
@Api(tags = "实名认证")
public class RealPeopleCertificationController {
	@Autowired
	private InitFaceVerifyService initFaceVerifyService;

	/**
	 * 开始认证前通过本接口获取CertifyId
	 *
	 * @param accessToken
	 * @param vo
	 * @return
	 * @author shun
	 * @date 2021年6月24日
	 */
	@PostMapping("/certifyid")
	@ResponseBody
	public ResultBean<Object> getCertifyId(@RequestHeader String accessToken,@RequestBody RealPeopleCertificationVO vo) {
		return initFaceVerifyService.getCertifyId(accessToken,vo);
	}




	/**
	 *认证回调接口
	 * @param certifyId
	 * @param passed
	 * @param subcode
	 * @return
	 */
	@GetMapping("/callBack")
	@ResponseBody
	public void callBack(String certifyId, String passed, String subcode) throws Exception {
		initFaceVerifyService.callBack(certifyId, passed, subcode);
	}



	/**
	 *认证结果接口
	 * @param certifyId
	 * @return
	 */
	@GetMapping("/verify")
	@ResponseBody
	public ResultBean<Object>  verify(String certifyId) {
		return initFaceVerifyService.verify(certifyId);
	}

	/**
	 * 身份证实名认证接口
	 * @param vo
	 * @return
	 */
	@PostMapping("/authentication")
	@ResponseBody
	public ResultBean<Object> authentication(@RequestHeader String accessToken,@RequestBody AuthenticationVo vo) {
		return initFaceVerifyService.authentication(accessToken,vo);
	}

	/**
	 * 人脸身份证实名认证接口
	 * @param vo
	 * @return
	 */
	@PostMapping("/FaceAuthentication")
	@ResponseBody
	@ApiOperation("人脸身份证实名认证接口")
	public ResultBean<Object> FaceAuthentication(@RequestHeader String accessToken,@RequestBody AuthenticationVo vo) {
		return initFaceVerifyService.faceAuthentication(accessToken,vo);
	}
	/**
	 * 修改已实名认证信息
	 * @param vo
	 * @return
	 */
	@PostMapping("/updateAuthentication")
	@ResponseBody
	@ApiOperation("修改已实名后信息")
	public ResultBean<Object> updateAuthentication(@RequestHeader String accessToken,@RequestBody AuthenticationVo vo) {
		return initFaceVerifyService.updateAuthentication(accessToken,vo);
	}

	/**
	 * 修改已实名认证信息并进行人脸认证
	 * @param vo
	 * @return
	 */
	@PostMapping("/updateFaceAuthentication")
	@ResponseBody
	@ApiOperation("修改已实名认证信息并进行人脸认证")
	public ResultBean<Object> updateFaceAuthentication(@RequestHeader String accessToken,@RequestBody AuthenticationVo vo) {
		return initFaceVerifyService.updateFaceAuthentication(accessToken,vo);
	}


	/**
	 * 人脸认证并下发智能锁授权
	 * @return
	 */
	@PostMapping("/FaceAuthIssueSmartLockAuth")
	@ResponseBody
	@RepeatSubmit
	public ResultBean<Object> faceAuthIssueSmartLockAuth(@RequestHeader String accessToken,@RequestBody AuthenticationVo vo){
		return initFaceVerifyService.faceAuthIssueSmartLockAuth(accessToken,vo);
	}


	/**
	 * 身份证ocr
	 * @return
	 */
	@PostMapping("/idCardOcr")
	@ResponseBody
	public ResultBean<Object> idCardOcr(@RequestHeader String accessToken,@RequestBody AuthenticationVo vo){
		return initFaceVerifyService.idCardOcr(accessToken,vo);
	}





}

